/*
 * Copyright 2016 The Cartographer Authors
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef SLAM_ROS_SLAM_ROS_NODE_CONSTANTS_H
#define SLAM_ROS_SLAM_ROS_NODE_CONSTANTS_H

#include <string>
#include <vector>
#include <array>

namespace slam_ros {

// Default topic names; expected to be remapped as needed.
constexpr char kLaserScanTopic[] = "scan";
constexpr char kMultiEchoLaserScanTopic[] = "echoes";
constexpr char kPointCloud2Topic[] = "points2";
constexpr char kImuTopic[] = "imu";
constexpr char kOdometryTopic[] = "/odom";
constexpr char kNavSatFixTopic[] = "fix";
constexpr char kLandmarkTopic[] = "landmark";
constexpr char kQRCodeTopic[] = "qr_code";
constexpr char kFinishTrajectoryServiceName[] = "finish_trajectory";
constexpr char kOccupancyGridTopic[] = "map";
constexpr char kScanMatchedPointCloudTopic[] = "scan_matched_points2";
constexpr char kRobotMatchedPointCloudTopic[] = "scan_matched_points";
constexpr char kSubmapListTopic[] = "submap_list";
constexpr char kSubmapQueryServiceName[] = "submap_query";
constexpr char kTrajectoryQueryServiceName[] = "trajectory_query";
constexpr char kStartTrajectoryServiceName[] = "start_trajectory";
constexpr char kWriteStateServiceName[] = "write_state";
constexpr char kGetTrajectoryStatesServiceName[] = "get_trajectory_states";
constexpr char kReadMetricsServiceName[] = "read_metrics";
constexpr char kTrajectoryNodeListTopic[] = "trajectory_node_list";
constexpr char kLandmarkPosesListTopic[] = "landmark_poses_list";
constexpr char kConstraintListTopic[] = "constraint_list";
constexpr char kSetOnlyUseOdomPredictPoseFlag[] = "useodom_predict_pose";

constexpr char kPgmToLocalizationMap[] = "pgm_to_localization_map";

constexpr char kQuerySlamStatus[] = "query_slamstatus";

constexpr char kControlSlam[] = "control_slam";

constexpr char kRobotStatus[] = "robot_status";
constexpr char kAgvRobotStatus[] = "agv_robot_status";
constexpr char kMappingTask[] = "enable_mapping";
constexpr char kExtendMappingTask[] = "enable_extend_mapping";
constexpr char kLocalizationTask[] = "enable_localization";
constexpr char kGetOccupancyGrid[] = "get_occupancy_map";
constexpr char kGetMapData[] = "get_map_data";
constexpr char kGetMapPng[] = "get_map_png";
constexpr char kOccupancyGridTopicName[] = "occupancy_grid";
constexpr char ksetInitPoseTask[] = "agv_old_relocate";
constexpr char ksetZoneTagInitPoseTask[] = "agv_relocate";
constexpr char kEditMap[] = "edit_map";

constexpr char kPoseWithConfidenceTopicName[] = "robot_pose";

constexpr char kagvPoseWithConfidenceTopicName[] = "pose";
constexpr char kagvConfidenceTopicName[] = "slam_confidence_score";
constexpr char kReflectorLandmarkTopicName[] = "reflector_landmark";
constexpr char kAgvLandmarkTopicName[] = "agv_reflector_landmark";
constexpr char kSetInitLocalizationPose[] = "set_init_localization_pose";
constexpr char kInitPoseName[] = "/initialpose";
const std::string kMapPath = std::string(getenv("HOME")) + "/map/slam_map/";
const std::string kCurrentMappingMap = kMapPath + "mapping";
const std::string kCurrentPose = kMapPath + "current_pose.txt" ;
const std::string kCurrentInitMapID = std::string(getenv("HOME")) + "/map/config/init_map.yaml" ;

constexpr char kSlamLogData[] = "slam_log_data";
constexpr double kConstraintPublishPeriodSec = 0.5;
constexpr double kTopicMismatchCheckDelaySec = 3.0;

constexpr double kDegreeToRadian = 3.14159/180.0;

constexpr int kInfiniteSubscriberQueueSize = 0;
constexpr int kLatestOnlyPublisherQueueSize = 1;

//add 2023/07/25
constexpr char kMappingLocalizationTask[] = "location_mode";
constexpr char kSaveMappingTask[] = "save_map";
constexpr char kGetMapListTask[] = "get_map_list";
constexpr char kGetLandmarkListsTask[] = "get_LandmarkLists";
// slam_types: 表示未知、定位、建图
enum SlamType {UNKNOWN = 0, LOCALIZATION, MAPPING, UPDATEMAPPING};

// For multiple topics adds numbers to the topic name and returns the list.
std::vector<std::string> ComputeRepeatedTopicNames(const std::string& topic,
                                                   int num_topics);

}  // namespace slam_ros

#endif  // SLAM_ROS_SLAM_ROS_NODE_CONSTANTS_H
